#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

int n;
map<string, pii> m;

string s;
int t;

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);
    
    cin >> n;
    int score = -1, idx = -1;

    for (int i = 1; i <= n; i++) {
        cin >> s >> t;
        if (m.find(s) == m.end()) {
            m[s] = {t, i};
        }
    }

    for (auto [k, v] : m) {
        if (v.first > score) {
            score = v.first, idx = v.second;
        }
    }
    cout << idx << endl;

    return 0;
}